﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ClientRegister
{
    public partial class StudentInfoDetailForm : Form
    {
        public StudentInfoDetailForm()
        {
            InitializeComponent();
        }

        private void btbClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnFind_Click(object sender, EventArgs e)
        {
            StudentDataProvider view = new StudentDataProvider();
            if (txtIDStuInput.Text != "")
            {
                DataTable dtview = view.loadInfo(txtIDStuInput.Text).Tables[0];
                if (dtview.Rows.Count > 0)
                {
                    txtID.Text = dtview.Rows[0].ItemArray[0].ToString();
                    txtName.Text = dtview.Rows[0].ItemArray[1].ToString();
                    txtGender.Text = dtview.Rows[0].ItemArray[2].ToString();
                    txtBirth.Text = dtview.Rows[0].ItemArray[3].ToString();
                    txtCareer.Text = dtview.Rows[0].ItemArray[4].ToString();
                    txtEmail.Text = dtview.Rows[0].ItemArray[5].ToString();
                    txtPhone.Text = dtview.Rows[0].ItemArray[6].ToString();
                    txtAddr.Text = dtview.Rows[0].ItemArray[7].ToString();
                    txtNote.Text = dtview.Rows[0].ItemArray[8].ToString();
                    txtCreateDate.Text = dtview.Rows[0].ItemArray[11].ToString();

                    ClassDataProvider viewAll = new ClassDataProvider();
                    gridListClass.DataSource = viewAll.LoadAllClassOfStu(txtID.Text).Tables[0];
                }
                else
                {
                    MessageBox.Show("Không tìm thấy thông tin học viên");
                }
            }
            else
            {
                MessageBox.Show("Nhập ID học viên trước");
            }
        }
    }
}
